FROM golang:latest as BUILDER
LABEL maintainer="zhangjianjun"

# build binary
RUN mkdir -p /go/src/gitee.com/openeuler/cve-agency-manager
COPY . /go/src/gitee.com/openeuler/cve-agency-manager
RUN cd /go/src/gitee.com/openeuler/cve-agency-manager && CGO_ENABLED=1 go build -v -o ./cve-agency-manager main.go

# copy binary config and utils
FROM openeuler/openeuler:21.03
RUN yum update && yum install -y python3 && yum install -y python3-pip
RUN mkdir -p /opt/app/ && mkdir -p /opt/app/conf/
COPY ./conf/product.conf /opt/app/conf/app.conf
# overwrite config yaml
COPY ./cve_tracking /opt/app/cve_tracking
RUN chmod 755 -R /opt/app/cve_tracking
RUN pip3 install --no-cache-dir -r /opt/app/cve_tracking/requirements.txt
COPY  --from=BUILDER /go/src/gitee.com/openeuler/cve-agency-manager/cve-agency-manager /opt/app/cve-agency-manager

WORKDIR /opt/app/
ENTRYPOINT ["/opt/app/cve-agency-manager"]
